<?php

	class ShopBrandController extends CommonController{

		public $model;

		public function __init(){

			parent:: __init();

			$this->model=K('Shop_brand');
		}

		public function index(){

			//调出老数据
			$brandData = $this->model->all();

			$this->assign('brandData',$brandData);

			$this->display();
		}

		public function brand_add(){

			if (IS_POST) {
				if (!$this->model->add_data()) {
					$this->error($this->model->error);
				}
				$this->success('添加数据成功');
			}

			$this->display();
		}

		public function brand_edit(){
			$bid = Q('get.bid',0,'intval');
			//调老数据
			$oldData = $this->model->where("bid={$bid}")->find();

			$this->assign('oldData',$oldData);
			#==========上传修改过的数据========================
			if (IS_POST) {
				$bid = Q('post.bid',0,'intval');
				if (!$this->model->edit_data($bid)) {

					$this->error($this->model->error);
				}
				$this->success('修改数据成功');
			}

			$this->display();
		}

		public function brand_del(){
			$bid = Q('get.bid',0,'intval');

			$this->model->del($bid);
			
			$this->success('删除品牌成功');
		}

	}
















?>